
package todolist.personalization;

/**
 * Controls application behaviour related to Temporal parsing and formatting.
 * Singleton class.
 * Currently allows getting only, may allow reading/setting/writing in the future.
 * @see java.util.Date
 * @see java.text.SimpleDateFormat
 * @author Ivan
 */
public class DateTimePatternCustomizer {

	// handle singleton instance

	private static DateTimePatternCustomizer _objDTPC;

	public static DateTimePatternCustomizer getInstance() {
		if (_objDTPC == null)
			_objDTPC = new DateTimePatternCustomizer();
		return _objDTPC;
	}
	
	// input DT temporal patterns
	
	private static final String[] DATE_INPUT_DATEONLY_PATTERNS = {
		"d/M/y", "d-M-y", // fields delimited
		"ddMMyy", // fields continuous
		"d MMM, y", "d MMM y", "MMM d, y", "MMM d y" // fields with text
		};
	private static final String[] DATE_INPUT_DATETIME_PATTERNS = {
		"d/M/y h:m a", "d-M-y h:m a", // fields delimited
		"d/M/y h:mma", "d-M-y h:mma",
		"d/M/y H:m", "d-M-y H:m",
		"d/M/y h a", "d-M-y h a", // fields delimited/continuous
		"d/M/y hha", "d-M-y hha",
		"d/M/y HHmm", "d-M-y HHmm",
		"ddMMyy h:m a", "ddMMyy h:mma", "ddMMyy H:m", // fields continuous/delimited
		"ddMMyy h a", "ddMMyy hha", "ddMMyy HHmm", // fields continuous
		"d MMM y h:m a", "MMM d y h:m a", // fields with text/delimited
		"d MMM y h:mma", "MMM d y h:mma",
		"d MMM y H:m", "MMM d y H:m",
		"d MMM y h a", "MMM d y h a", // fields with text/continuous
		"d MMM y hha", "MMM d y hha",
		"d MMM y HHmm", "MMM d y HHmm"
		};

	// display DT temporal patterns
	
	private static final String DATE_DISPLAY_DATEONLY = "dd/MM/yyyy";
	private static final String DATE_DISPLAY_DATETIME = "dd/MM/yyyy HH:mm";
	
	// voice friendly DT temporal patterns
	
	private static final String DATE_VOICE_DATEONLY = "EEEE, d MMMM yyyy";
	private static final String DATE_VOICE_DATETIME = "EEEE, d MMMM yyyy, HH:mm";
	
	// input DT temporal patterns
	
	/**
	 * Returns all allowed Date, without time, patterns that can be parsed.
	 */
	public String[] getInputDateOnlyPatterns() {
		return DATE_INPUT_DATEONLY_PATTERNS;
	}
	
	/**
	 * Returns all allowed Date, with time, patterns that can be parsed.
	 */
	public String[] getInputDateTimePatterns() {
		return DATE_INPUT_DATETIME_PATTERNS;
	}

	// display DT temporal patterns
	
	/**
	 * Pattern of how Date without time is to be displayed.
	 */
	public String getDisplayDateOnlyPattern() {
		return DATE_DISPLAY_DATEONLY;
	}
	
	/**
	 * Pattern of how Date with time is to be displayed.
	 */
	public String getDisplayDateTimePattern() {
		return DATE_DISPLAY_DATETIME;
	}

	/**
	 * Pattern of how Date without time is to be presented for TTS.
	 */
	public String getVoiceDateOnlyPattern() {
		return DATE_VOICE_DATEONLY;
	}
	
	/**
	 * Pattern of how Date with time is to be presented for TTS.
	 */
	public String getVoiceDateTimePattern() {
		return DATE_VOICE_DATETIME;
	}
	
}
